package 回溯算法;

import java.util.ArrayList;
import java.util.List;

public class 递增子序列 {
    class Solution{
        List<List<Integer>> reslut = new ArrayList<>();
        List<Integer> path = new ArrayList<>();
        public List<List<Integer>> findSubsequences(int[] nums){
            backTracking(nums,0);
            return reslut;
        }

        private void backTracking(int[] nums, int startIndex) {
            if (path.size()>1){
                reslut.add(new ArrayList<>(path));
            }
            int[] used = new int[201];
            for (int i = startIndex; i < nums.length; i++) {
                //这里应该是数值的范围要求
                if (!path.isEmpty() && nums[i] < path.get(path.size() - 1) ||
                        (used[nums[i] + 100] == 1)) continue;
                used[nums[i] + 100] = 1;
                path.add(nums[i]);
                backTracking(nums,i+1);
                path.remove(path.size()-1);
            }
        }
    }
}
